dirs = ext expat lbfgs data mn bn pll circuit util dn2mn acbn acve acopt \
       cl inference fminbr dnlearn mnlearnw acmn idspn mtlearn

targets = begin_ $(dirs:=_)

all: $(targets)

clean: 
	if [ -d lib ]; then rm lib/*; fi
	for d in $(dirs); do \
	cd $$d && $(MAKE) clean; \
	cd ..; \
	done;

begin_:
	@if [ ! -d ../bin ]; then mkdir ../bin; fi
	@if [ ! -d lib ]; then mkdir lib; fi

ext_: force_look
	cd ext && $(MAKE)

expat_: force_look
	cd expat && $(MAKE) allopt

lbfgs_: force_look
	cd lbfgs && $(MAKE) $(MFLAGS)

data_: force_look
	cd data && $(MAKE) $(MFLAGS)

mn_: force_look
	cd mn && $(MAKE) $(MFLAGS)

bn_: force_look
	cd bn && $(MAKE) $(MFLAGS)

pll_: force_look
	cd pll && $(MAKE) $(MFLAGS)

circuit_: force_look
	cd circuit && $(MAKE) $(MFLAGS)

util_: force_look
	cd util && $(MAKE) $(MFLAGS)

dn2mn_: force_look
	cd dn2mn && $(MAKE) $(MFLAGS)

acbn_: force_look
	cd acbn && $(MAKE) $(MFLAGS)


acmn_: force_look
	cd acmn && $(MAKE) $(MFLAGS)

mtlearn_: force_look
	cd mtlearn && $(MAKE) $(MFLAGS)

idspn_: force_look
	cd idspn && $(MAKE) $(MFLAGS)


acve_: force_look
	cd acve && $(MAKE) $(MFLAGS)

acopt_: force_look
	cd acopt && $(MAKE) $(MFLAGS)

cl_: force_look
	cd cl && $(MAKE) $(MFLAGS)

inference_: force_look
	cd inference && $(MAKE) $(MFLAGS)

fminbr_: force_look
	cd fminbr && $(MAKE) $(MFLAGS)

dnlearn_: force_look
	cd dnlearn && $(MAKE) $(MFLAGS)

mnlearnw_: force_look
	cd mnlearnw && $(MAKE) $(MFLAGS)

force_look:
	true
